import request from '@/utils/request'
// import qs from 'qs'

// 删除病毒防御
export function delAv (params) {
  var data = fromData(params)
  return request({
    url: '/av/del_av',
    method: 'post',
    data
  })
}

// 增加病毒防御
export function addAv (params) {
  var data = fromData(params)
  return request({
    url: '/av/addAv',
    method: 'post',
    data
  })
}

// 编辑病毒防御
export function editAv (params) {
  var data = fromData(params)
  return request({
    url: '/av/editAv',
    method: 'post',
    data
  })
}

// 获取AV防护策略列表
export function getAvArray (params) {
  var data = fromData(params)
  return request({
    url: '/av/getAvArray',
    method: 'post',
    data
  })
}

// 获取病毒防御信息
export function getAvInfo (params) {
  var data = fromData(params)
  return request({
    url: '/av/getAvInfo',
    method: 'post',
    data
  })
}

// 修改AV全局配置
export function setAvConfig (params) {
  var data = fromData(params)
  return request({
    url: '/av/setAvConfig',
    method: 'post',
    data
  })
}

// 获取AV全局配置
export function getAvConfig (params) {
  var data = fromData(params)
  return request({
    url: '/av/getAvConfig',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
